﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel.Description;
using System.ServiceModel;
using System.Web.Services;
using System.Web.Script.Services;
using ZX.BLL.EHR.Time;
using ZX.BLL.EHR;
using ZX.CRM.Bussiness;
using ZX.CRM.Library;
namespace ZX.WebApp.Extend
{
    public partial class BpmLibraryManager : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 计算请假天数
        /// </summary>
        /// <param name="workFlowInstanceId"></param>
        /// <param name="title"></param>
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string HRGetEmpTotalVation(string EmployeeID, string FrmDatetime, string TODatetime, string IsIncludeHoliday)
        {
            string strWorkMsg = "";
            try
            {
                if (!string.IsNullOrEmpty(EmployeeID) && !string.IsNullOrEmpty(FrmDatetime) && !string.IsNullOrEmpty(TODatetime)
                    && !string.IsNullOrEmpty(IsIncludeHoliday))
                {
                    float LeaveDay=0.0f;
                    float LeaveTime = 0.0f;
                    string Msg="";
                    Ehr_Scheduling sch = new Ehr_Scheduling();
                    LeaveTime=sch.HRGetEmpTotalVation(new Guid(EmployeeID), Convert.ToDateTime(FrmDatetime), Convert.ToDateTime(TODatetime),
                        Convert.ToInt32(IsIncludeHoliday), out  LeaveDay, out Msg);

                    strWorkMsg = "OK%@" + LeaveDay.ToString("F2") + "|" + LeaveTime.ToString("F2") + "|" + Msg;
                }
            }
            catch (Exception ex)
            {
                strWorkMsg = "ERR%@" + ex.Message;
            }
            return strWorkMsg;

        }

        /// <summary>
        /// 获取指定员工的打卡记录。
        /// </summary>
        /// <param name="workFlowInstanceId"></param>
        /// <param name="title"></param>
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string EmpwkCardData(string EmployeeID, string CardDate)
        {
            string strWorkMsg = "";
            try
            {

                if (!string.IsNullOrEmpty(EmployeeID) && !string.IsNullOrEmpty(CardDate))
                {
                   
                    Ehr_EmpwkCardData wkCardData = new Ehr_EmpwkCardData(new Guid(EmployeeID), CardDate);


                    strWorkMsg = "OK%@" + wkCardData.MinCardTime + "|" + wkCardData.MaxCardTime;
                }
            }
            catch (Exception ex)
            {
                strWorkMsg = "ERR%@" + ex.Message;
            }
            return strWorkMsg;

        }

        /// <summary>
        /// 指定岗位名获得职级名称
        /// </summary>
        /// <param name="PostID"></param>
        /// <returns></returns>
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string GetPostRankName(string PostID)
        {
            string strWorkMsg = "";
            try
            {

                if (!string.IsNullOrEmpty(PostID))
                {

                    BDatPost dp = new BDatPost();
                    string PostRankName = dp.GetPostRankName(PostID);


                    strWorkMsg = "OK%@" + PostRankName;
                }
            }
            catch (Exception ex)
            {
                strWorkMsg = "ERR%@" + ex.Message;
            }
            return strWorkMsg;

        }

        ///// <summary>
        ///// 指定公开课期数记录
        ///// </summary>
        ///// <param name="PostID"></param>
        ///// <returns></returns>
        //[WebMethod]
        //[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        //public static string GetCrmProductLayout(string ProductLayoutID)
        //{
        //    string strWorkMsg = "";
        //    try
        //    {
        //        if (!string.IsNullOrEmpty(ProductLayoutID))
        //        {
        //            CrmProductLayout cpl =CrmProductLayout.Get(new Guid(ProductLayoutID));
        //            strWorkMsg = "OK%@" + cpl.BeginDate+"|"+cpl.EndDate+"|"+cpl.Place;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        strWorkMsg = "ERR%@" + ex.Message;
        //    }
        //    return strWorkMsg;

        //}


        /// <summary>
        /// 公开课费用明细记录
        /// </summary>
        /// <param name="PostID"></param>
        /// <returns></returns>
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static string GetSubjectList()
        {
            string strWorkMsg = "";
            try
            {

                BCrmSubjectManager csm = new BCrmSubjectManager();
                List<BCrmSubjectManager.SubjectList> TFlist = new List<BCrmSubjectManager.SubjectList>();
                TFlist = csm.GetSubjectList();
                strWorkMsg = ZX.Common.Globals.ObjectToJSON(TFlist);
            }
            catch (Exception ex)
            {
                strWorkMsg = "ERR%@" + ex.Message;
            }
            return strWorkMsg;

        }
    }
}